package logic;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import data.SystemData;

import exceptions.ObjectAlreadyInitializedException;
import gui.frmMain;

public class Main {
	public static void main(String[] args){
		//reset all handlers
		//read from xml
		//initialize logger
		//initialize facades
		//set up gui
		try {
			Facade.init(new SystemHandler(), new AdminHandler() , new UserHandler(),new CorrelationRecAlgorithm());  //creates all the handlers
			//SystemData.doXML();  //initializes the system data and reads from xml
			SystemData.doSQL();  //initializes the system data and reads from xml
			Logger.getInstance().systemStart();
			frmMain mainFrame = new frmMain();
			mainFrame.addWindowListener(new WindowAdapter(){
				@Override
				public void windowClosed(WindowEvent e) {
					Facade.getInstance().exit();
				}
				@Override
				public void windowClosing(WindowEvent e) {
				}
			});
			mainFrame.setVisible(true);
			ToGuiFacade.init(mainFrame);
			//mainFrame.showMovieScreen("Tal");
		} catch (ObjectAlreadyInitializedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
